//
//  XNStatus.swift
//  weibo
//
//  Created by 王向宁 on 16/5/24.
//  Copyright © 2016年 王向宁. All rights reserved.
//

import UIKit

class XNStatus: NSObject {
    
    //自动匹配机型对应的平台
    var id: Int64 = 0
    
    //微博内容
    var text : String?
    
    var created_at : String?
    
    var source : String?
    
    var user : XNUser?
    
    var retweeted_status: XNStatus?
    
    var pic_urls: [XNPicture]?
    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String : AnyObject] {
                
                user = XNUser(dict: dict)
            }
            return
        }
        
        if key == "retweeted_status" {
            if let dict = value as? [String : AnyObject] {
                
                retweeted_status = XNStatus(dict: dict)
            }
            return
        }
        
        if key == "pic_urls" {
            if let array = value as? [[String : AnyObject]] {
                var temparray = [XNPicture]()
                
                for item in array {
                    let p = XNPicture(dict: item)
                    
                    temparray.append(p)
                }
                pic_urls = temparray
                
            }
            return
        }

        super.setValue(value, forKey: key)
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    
    
    

}
